package com.yue92.datalife;

import com.alibaba.nacos.api.config.annotation.NacosConfigListener;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import com.spring4all.swagger.EnableSwagger2Doc;
import com.yue92.datalife.service.ICustomExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;

import java.util.Properties;
import java.util.TimeZone;

@SpringBootApplication(exclude= {UserDetailsServiceAutoConfiguration.class, KafkaAutoConfiguration.class})
@EnableSwagger2Doc
//@NacosPropertySource(dataId = "com.yue92.datalife.all.properties", autoRefreshed = true)
public class DatalifeApplication {

	@Autowired
	private ICustomExecutor customExecutor;

	public static void main(String[] args) {
		TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

		SpringApplication.run(DatalifeApplication.class, args);
	}

//	@NacosConfigListener(dataId = "com.yue92.datalife.all.properties")
	public void onMessage(Properties config) {
		int coreSize = Integer.parseInt(config.getProperty("core-size", "4"));
		int maxSize = Integer.parseInt(config.getProperty("max-size", "16"));

		customExecutor.setParams(coreSize, maxSize);
	}
}
